import { SubjectComponent } from "../../../../core/subject";
import Bullet from "../../bullet";
const { ccclass, property } = cc._decorator;
@ccclass
export default class BulletItem extends SubjectComponent {
    @property(cc.Label)
    lb: cc.Label = null;

    @property(cc.Node)
    bg: cc.Node = null;

    bullet: Bullet = null;
    setData(bullet: Bullet) {
        this.bullet = bullet;
        this.lb.string = this.bullet.name;
    }

    protected onLoad(): void {
        this.node.on(cc.Node.EventType.TOUCH_END, this.onClick, this);
        this.node.on(cc.Node.EventType.MOUSE_ENTER, this.onMouseEnter, this);
        this.node.on(cc.Node.EventType.MOUSE_LEAVE, this.onMouseLeave, this);
    }
    onMouseEnter(evt: cc.Node.EventType) {
        this.bg.opacity = 80;
        this.emit("mouse-enter", this);
    }
    onMouseLeave(evt: cc.Node.EventType) {
        this.bg.opacity = 0;
        this.emit("mouse-leave", this);
    }
    onClick() {
        this.emit("click", this);
    }

    onClickDel() {
        this.emit("del", this);
    }
};